


// 活动 banner 楼层跳转
export const pageSkipping = (path, param) => {
	if (path === 'category') {
		uni.switchTab({ url: '/pages/classification/index' })
	} else if (path === 'coupon') {
		uni.navigateTo({ url: '/subpackage/personalCenter/coupon' })
	} else if (path === 'COUPON') {
		uni.navigateTo({ url: '/subpackage/personalCenter/coupon' })
	} else if (path === 'BRAND') {
		uni.navigateTo({ url: `/subpackage/manufactor/index?url=${path}&id=${param.id}` })
	} else if (path === 'search') {
		uni.navigateTo({ url: `/pages_search/index?keyword=${param.keyword || param.title}` })
	} else if (path === 'PORTFOLIO') {
		uni.navigateTo({ url: `/subpackage/activity/portfolio` })
	} else {
		uni.navigateTo({ url: `/subpackage/activity/activity?promotionType=${path}&title=${param.title}` })
	}
}


// 函数防抖
// desc: 短时间内多次触发同一事件，只执行最后一次，或者只执行最开始的一次，中间的不执行
export const debounce = (fn, interval) => {
	let timeId = 0
	let gapTime = interval || 1000; //间隔时间，如果interval不传，则默认1000ms
	return function () {
		clearTimeout(timeId);
		timeId = setTimeout(function () {
			fn
		}, gapTime);
	}
}
export const calculate = (e) => {
	if (!e) return
	let a = (e + '').split('.')[1]
	return a.slice(0, 1) + '.' + a.slice(1)
}
export const calculateTime = (e) => {
	if (!e) return
	try {
		let a = e.split(' ');
		let b = a[1].split(':');
		a = a[0].replace(/-/g, '.');
		return a;
	} catch (error) {
		return '';
	}
}

